package com.orkasgb.framework.hadoop.mapperreduce.partitioner;

import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class ClassPartitioner extends Partitioner<Text, PartitionerEntity> {

    @Override
    public int getPartition(Text text, PartitionerEntity partitionerEntity, int i) {
        final String classes = partitionerEntity.getClasses();

        if (StringUtils.equals("一班", classes)) {
            return 0;
        } else if (StringUtils.equals("二班", classes)) {
            return 1;
        } else {
            return 2;
        }
    }
}
